<template>
  <div class="order">
    <div class="tab">
        <van-tabs v-model:active="active" >
          <van-tab title="全部订单">
          </van-tab>
          <van-tab title="待支付的订单">
          </van-tab>
      </van-tabs>
    </div>
    <div class="content">
      <template v-if="!active">
        <template v-for="item in allOrder">
          <OrderItem :item="item"></OrderItem>
        </template>
      </template>
      <template v-else>
        <template v-for="item in pend">
          <OrderItem :item="item"></OrderItem>
        </template>
      </template>
    </div>
  </div>
</template>

<script setup>
import {ref} from "vue"
import OrderItem from './kids/OrderItem.vue';
import useOrdeerStore from '@/stores/modules/order';
import { storeToRefs } from 'pinia';

const orderStore = useOrdeerStore()
if (orderStore.allOrder.length === 0) orderStore.getAllOrder()
if (orderStore.pend.length === 0) orderStore.getPend()
const {allOrder,pend} = storeToRefs(orderStore)


const active = ref(0)
</script>

<style lang="less" scoped>
.order {
  .tab {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    z-index: 10;
    ::v-deep(.van-tabs--line .van-tabs__wrap) {
      height: 30px;
    }
    ::v-deep(.van-tab){
      font-size: 12px;
    }
  }
  .content {
    margin: 20px 0 30px;
  }
}
</style>